package com.ruoyi.work.controller;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.work.domain.TbRescueTeam;
import com.ruoyi.work.service.ITbRescueTeamService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 救援队伍台账Controller
 *
 * @author szm
 * @date 2025-10-21
 */
@Api(tags = "救援队伍台账")
@RestController
@RequestMapping("/work/TbRescueTeam")
public class TbRescueTeamController extends BaseController {
    @Autowired
    private ITbRescueTeamService tbRescueTeamService;

    /**
     * 查询救援队伍台账列表
     */
    @ApiOperation("查询救援队伍台账列表")
    @GetMapping("/list")
    public TableDataInfo list(TbRescueTeam entity, HttpServletRequest req) {
        startPage();
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.setEntity(entity);
        List<TbRescueTeam> list = tbRescueTeamService.list(wrapper);
        return getDataTable(list);
    }

    /**
     * 导出救援队伍台账列表
     */
    @ApiOperation("导出救援队伍台账列表")
    @Log(title = "救援队伍台账", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public void export(HttpServletResponse response, TbRescueTeam entity) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.setEntity(entity);
        List<TbRescueTeam> list = tbRescueTeamService.list(wrapper);
        ExcelUtil<TbRescueTeam> util = new ExcelUtil<TbRescueTeam>(TbRescueTeam. class);
        util.exportExcel(response, list, "救援队伍台账数据");
    }

    /**
     * 获取救援队伍台账详细信息
     */
    @ApiOperation("获取救援队伍台账详细信息")
    @GetMapping(value = "/getById")
    public AjaxResult getById(@RequestParam("id") String id) {
        return success(tbRescueTeamService.getById(id));
    }

    /**
     * 新增救援队伍台账
     */
    @ApiOperation("新增/修改救援队伍台账")
    @Log(title = "救援队伍台账", businessType = BusinessType.INSERT)
    @PostMapping("/save")
    public AjaxResult save(@RequestBody TbRescueTeam entity) {
        return toAjax(tbRescueTeamService.saveOrUpdate(entity));
    }

    /**
     * 删除救援队伍台账
     */
    @ApiOperation("删除救援队伍台账")
    @Log(title = "救援队伍台账", businessType = BusinessType.DELETE)
    @PostMapping("/delIds")
    public AjaxResult remove(@RequestParam("ids") String ids) {
        return toAjax(tbRescueTeamService.removeById(ids));
    }
}
